import java.util.ArrayList;


public class AccountHolder extends User {
	private ArrayList<Account> accounts;
	
	public AccountHolder (String name, String number, String address, String id) {
		super(name, number, address, id);
		userType = ACCOUNT_HOLDER;
	}
	
	public Account getAccount(int accountNumber) {
		Account requestedAccount = null;
		for (int i = 0; i < accounts.size(); i++) {
			if (accounts.get(i).getAccountNumber() == accountNumber)
				requestedAccount = accounts.get(i);
		}
		return requestedAccount;
	}
	
	public boolean addAccount(int accountType, int accountNumber, double initialDeposit) {
		Account newAccount;
		if (accountType == 100) {
			if (initialDeposit <= 0.0) {
				newAccount = new Checking(this.name, accountNumber);
				accounts.add(newAccount);
				return true;
			}
			else {
				newAccount = new Checking(this.name, accountNumber, initialDeposit);
				accounts.add(newAccount);
				return true;
			}
		}
		else if (accountType == 200) {
			if (initialDeposit <= 0.0) {
				newAccount = new Savings(this.name, accountNumber);
				accounts.add(newAccount);
				return true;
			}
			else {
				newAccount = new Savings(this.name, accountNumber, initialDeposit);
				accounts.add(newAccount);
				return true;
			}
		}
		else
			return false;
	}
}
